// SPDX-License-Identifier: GPL-2.0
/*
 * dts file for Hisilicon HiKey960 Development Board
 *
 * Copyright (C) 2016, Hisilicon Ltd.
 *
 */

/dts-v1/;

#include "hi3660.dtsi"
#include "hikey960-pinctrl.dtsi"
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
#include <dt-bindings/interrupt-controller/irq.h>

/ {
	model = "HiKey960";
	compatible = "hisilicon,hi3660-hikey960", "hisilicon,hi3660";

	aliases {
		mshc1 = &dwmmc1;
		mshc2 = &dwmmc2;
		serial0 = &uart0;
		serial1 = &uart1;
		serial2 = &uart2;
		serial3 = &uart3;
		serial4 = &uart4;
		serial5 = &uart5;
		serial6 = &uart6;
	};

	chosen {
		stdout-path = "serial6:115200n8";
	};

	memory@0 {
		device_type = "memory";
		/* rewrite this at bootloader */
		reg = <0x0 0x0 0x0 0x0>;
	};

	reserved-memory {
		#address-cells = <2>;
		#size-cells = <2>;
		ranges;

		ramoops@32000000 {
			compatible = "ramoops";
			reg = <0x0 0x32000000 0x0 0x00100000>;
			record-size	= <0x00020000>;
			console-size	= <0x00020000>;
			ftrace-size	= <0x00020000>;
		};
	};

	reboot-mode-syscon@32100000 {
		compatible = "syscon", "simple-mfd";
		reg = <0x0 0x32100000 0x0 0x00001000>;

		reboot-mode {
			compatible = "syscon-reboot-mode";
			offset = <0x0>;

			mode-normal	= <0x77665501>;
			mode-bootloader	= <0x77665500>;
			mode-recovery	= <0x77665502>;
		};
	};

	keys {
		compatible = "gpio-keys";
		pinctrl-names = "default";
		pinctrl-0 = <&pwr_key_pmx_func &pwr_key_cfg_func>;

		power {
			wakeup-source;
			gpios = <&gpio4 2 GPIO_ACTIVE_LOW>;
			label = "GPIO Power";
			linux,code = <KEY_POWER>;
		};
	};

	leds {
		compatible = "gpio-leds";

		user_led1 {
			label = "user_led1";
			/* gpio_150_user_led1 */
			gpios = <&gpio18 6 0>;
			linux,default-trigger = "heartbeat";
		};

		user_led2 {
			label = "user_led2";
			/* gpio_151_user_led2 */
			gpios = <&gpio18 7 0>;
			linux,default-trigger = "mmc0";
		};

		user_led3 {
			label = "user_led3";
			/* gpio_189_user_led3 */
			gpios = <&gpio23 5 0>;
			default-state = "off";
		};

		user_led4 {
			label = "user_led4";
			/* gpio_190_user_led4 */
			gpios = <&gpio23 6 0>;
			linux,default-trigger = "cpu0";
		};

		wlan_active_led {
			label = "wifi_active";
			/* gpio_205_wifi_active */
			gpios = <&gpio25 5 0>;
			linux,default-trigger = "phy0tx";
			default-state = "off";
		};

		bt_active_led {
			label = "bt_active";
			gpios = <&gpio25 7 0>;
			/* gpio_207_user_led1 */
			linux,default-trigger = "hci0-power";
			default-state = "off";
		};
	};

	pmic: pmic@fff34000 {
		compatible = "hisilicon,hi6421v530-pmic";
		reg = <0x0 0xfff34000 0x0 0x1000>;
		interrupt-controller;
		#interrupt-cells = <2>;

		regulators {
			ldo3: LDO3 { /* HDMI */
				regulator-name = "VOUT3_1V85";
				regulator-min-microvolt = <1800000>;
				regulator-max-microvolt = <2200000>;
				regulator-enable-ramp-delay = <120>;
			};

			ldo9: LDO9 { /* SDCARD I/O */
				regulator-name = "VOUT9_1V8_2V95";
				regulator-min-microvolt = <1750000>;
				regulator-max-microvolt = <3300000>;
				regulator-enable-ramp-delay = <240>;
			};

			ldo11: LDO11 { /* Low Speed Connector */
				regulator-name = "VOUT11_1V8_2V95";
				regulator-min-microvolt = <1750000>;
				regulator-max-microvolt = <3300000>;
				regulator-enable-ramp-delay = <240>;
			};

			ldo15: LDO15 { /* UFS VCC */
				regulator-name = "VOUT15_3V0";
				regulator-min-microvolt = <1750000>;
				regulator-max-microvolt = <3000000>;
				regulator-boot-on;
				regulator-always-on;
				regulator-enable-ramp-delay = <120>;
			};

			ldo16: LDO16 { /* SD VDD */
				regulator-name = "VOUT16_2V95";
				regulator-min-microvolt = <1750000>;
				regulator-max-microvolt = <3000000>;
				regulator-enable-ramp-delay = <360>;
			};
		};
	};

	wlan_en: wlan-en-1-8v {
		compatible = "regulator-fixed";
		regulator-name = "wlan-en-regulator";
		regulator-min-microvolt = <1800000>;
		regulator-max-microvolt = <1800000>;

		/* GPIO_051_WIFI_EN */
		gpio = <&gpio6 3 0>;

		/* WLAN card specific delay */
		startup-delay-us = <70000>;
		enable-active-high;
	};

	firmware {
		optee {
			compatible = "linaro,optee-tz";
			method = "smc";
		};
	};
};

&i2c0 {
	/* On Low speed expansion */
	label = "LS-I2C0";
	status = "okay";
};

&i2c1 {
	status = "okay";

	adv7533: adv7533@39 {
		status = "ok";
		compatible = "adi,adv7533";
		reg = <0x39>;
		adi,dsi-lanes = <4>;
		ports {
			#address-cells = <1>;
			#size-cells = <0>;
			port@0 {
				reg = <0>;
			};
			port@1 {
				reg = <1>;
			};
		};
	};
};

&i2c7 {
	/* On Low speed expansion */
	label = "LS-I2C1";
	status = "okay";
};

&uart3 {
	/* On Low speed expansion */
	label = "LS-UART0";
	status = "okay";
};

&uart4 {
	status = "okay";

	bluetooth {
		compatible = "ti,wl1837-st";
		enable-gpios = <&gpio15 6 GPIO_ACTIVE_HIGH>;
		max-speed = <3000000>;
	};
};

&uart6 {
	/* On Low speed expansion */
	label = "LS-UART1";
	status = "okay";
};

&spi2 {
	/* On Low speed expansion */
	label = "LS-SPI0";
	status = "okay";
};

&spi3 {
	/* On High speed expansion */
	label = "HS-SPI1";
	status = "okay";
};

&dwmmc1 {
	vmmc-supply = <&ldo16>;
	vqmmc-supply = <&ldo9>;
	status = "okay";
};

&dwmmc2 { /* WIFI */
	broken-cd;
	/* WL_EN */
	vmmc-supply = <&wlan_en>;
	ti,non-removable;
	non-removable;
	#address-cells = <0x1>;
	#size-cells = <0x0>;
	status = "ok";

	wlcore: wlcore@2 {
		compatible = "ti,wl1837";
		reg = <2>;      /* sdio func num */
		/* WL_IRQ, GPIO_179_WL_WAKEUP_AP */
		interrupt-parent = <&gpio22>;
		interrupts = <3 IRQ_TYPE_EDGE_RISING>;
	};
};
